
let ctx;
let circleX = 150;    // 圆心X坐标
let circleY = 144;    // 圆心Y坐标

// 方向箭头与动态红白弧度不能同步，暂不使用 参考小米指南针
let arcDynamic = (id, angel) => {
  let r = 120;
  let direction;
  if (angel > Math.PI) {
    direction = false; //绘图方向 顺时针
    angel = 1.5 * Math.PI - angel;
  } else {
    direction = true; //绘图方向 逆时针
    angel = -0.5 * Math.PI - angel;
  }
  ctx = wx.createCanvasContext(id);
  ctx.beginPath();
  ctx.strokeStyle = "red";
  ctx.arc(circleX, circleY, r, -0.5 * Math.PI, angel + 0.05, direction);
  ctx.stroke();
  ctx.beginPath();
  ctx.strokeStyle = "white";
  ctx.arc(circleX, circleY, r, -0.5 * Math.PI, 2 * Math.PI + angel - 0.05, !direction);
  ctx.stroke();

  ctx.draw();
  // requestAnimationFrame(arc);
}

let arc = (id) => {
  let r = 110;

  ctx = wx.createCanvasContext(id);
  ctx.beginPath();
  ctx.strokeStyle = "#FF4040"; //350d0d  8B2323
  ctx.arc(circleX, circleY, r, 0, 2 * Math.PI, false);
  ctx.stroke();

  r = 143
  ctx.beginPath();
  ctx.strokeStyle = "#510a0a";
  ctx.arc(circleX, circleY, r, 0.6 * Math.PI, 1.3 * Math.PI, false);
  ctx.stroke();

  ctx.beginPath();
  ctx.strokeStyle = "#4D4D4D";
  ctx.arc(circleX, circleY, r, 1.3 * Math.PI, 1.47 * Math.PI, false);
  ctx.stroke();

  ctx.beginPath();
  ctx.strokeStyle = "#4D4D4D";
  ctx.arc(circleX, circleY, r, -0.47 * Math.PI, 0.25 * Math.PI, false);
  ctx.stroke();

  ctx.beginPath();
  ctx.strokeStyle = "#858585";
  ctx.arc(circleX, circleY, r, 0.25 * Math.PI, 0.4 * Math.PI, false);
  ctx.stroke();

  ctx.draw();
}

module.exports = {
  arc: arc
}